package com.example.example.config;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

@Configuration
public class ChatConfig {

    @Bean("deepseekStreamingChatModel")
    public StreamingChatLanguageModel deepseekStreamingChatModel() {
        // DeepSeek流式输出模型配置
        return OpenAiStreamingChatModel.builder()
                .baseUrl("https://api.deepseek.com/v1")
                .apiKey(System.getenv("DEEPSEEK_KEY"))
                .modelName("deepseek-kimiChat")
                .maxTokens(4096)
                .temperature(0.7)
                .timeout(Duration.ofSeconds(60))
                .build();
    }

    @Bean("kimiStreamingChatModel")
    public StreamingChatLanguageModel kimiStreamingChatModel() {
        // Kimi流式输出模型配置
        return OpenAiStreamingChatModel.builder()
                .baseUrl("https://api.moonshot.cn/v1")
                .apiKey(System.getenv("KIMI_KEY"))
                .modelName("moonshot-v1-8k")
                .maxTokens(4096)
                .temperature(0.7)
                .timeout(Duration.ofSeconds(60))
                .build();
    }

    @Bean("kimiChatLanguageModel")
    public ChatLanguageModel kimiChatLanguageModel() {
        return OpenAiChatModel.builder()
                .baseUrl("https://api.moonshot.cn/v1")
                .apiKey(System.getenv("KIMI_KEY"))
                .modelName("moonshot-v1-8k")
                .maxTokens(4096)
                .temperature(0.7)
                .timeout(Duration.ofSeconds(60))
                .build();
    }

}
